package com.web.biz.brandweb.service;
import com.css.sword.kernel.base.annotation.Service;
import com.css.sword.kernel.base.annotation.ServiceContainer;
import com.css.sword.kernel.base.persistence.IPersistenceService;
import com.css.sword.kernel.base.persistence.SQLParam;
import com.css.sword.kernel.utils.SwordLogUtils;
import com.css.sword.kernel.utils.SwordPersistenceUtils;
import com.css.sword.platform.web.event.IReqData;
import com.css.sword.platform.web.event.IResData;
import com.css.sword.platform.web.event.SwordRes;
import com.web.common.dataDictionary.PO.TCategoryShopPO;
import com.web.common.utils.LoginInfoUtil;

@ServiceContainer
public class BrandInvoiceService {

	private static SwordLogUtils log = SwordLogUtils.getLogger(BrandInvoiceService.class);
	private final static String curpath = "/pages/biz/brand/";
	public BrandInvoiceService() throws Exception {
		super();
	}


	/**
	 * 商户保存发票信息
	 * @param req
	 * @return
	 * @throws Exception
	 */
	@Service(serviceName = "BrandInvoiceService_update")
	public IResData update(IReqData req) throws Exception {

		log.debug("开始进入 BrandInvoiceService_update 方法。");

		IPersistenceService dao = SwordPersistenceUtils.getPersistenceService();
		IResData res = new SwordRes();
		String szflag = "false";
		try {
			TCategoryShopPO shopPO = (TCategoryShopPO) req.getForm("form_brandinvoice",TCategoryShopPO.class);
			if (dao.updatePO(shopPO) >= 0) {
				szflag = "true";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		res.addAttr("szflag", szflag);
		return res;
	}

	 		
	/**
	 * 初始化发票信息表单
	 * @param req
	 * @return
	 * @throws Exception
	 */
	@Service(serviceName = "BrandInvoiceService_initForm")
	public IResData initForm(IReqData req) throws Exception {

		log.debug("开始进入 BrandInvoiceService_initForm 方法。");

		IPersistenceService dao = SwordPersistenceUtils.getPersistenceService();

		IResData res = new SwordRes();
		SQLParam param = new SQLParam();
		param.addParam(LoginInfoUtil.getLoginUserName());
		TCategoryShopPO shopPO = dao.queryPOByKey("grxx_queryShopxxByYhm", param, TCategoryShopPO.class);
		res.addForm("form_brandinvoice", shopPO.toMap());
		
		res.addPage(curpath+"brandInvoiceForm.jsp");
		return res;

	}

	 		


}